package com.example.chartmoudel;

import android.graphics.Color;

import com.github.mikephil.charting.charts.PieChart;
import com.github.mikephil.charting.data.PieData;
import com.github.mikephil.charting.data.PieDataSet;
import com.github.mikephil.charting.formatter.PercentFormatter;

/**
 * Created by xy on 2017/12/10.
 */

public class PieChartManger {

    private static PieChart mPieChart;

    public static void init(PieChart pieChart){
        mPieChart=pieChart;
        mPieChart.setUsePercentValues(true);
        mPieChart.setRotationEnabled(false);
        mPieChart.getLegend().setEnabled(false);
        mPieChart.getDescription().setEnabled(false);
        mPieChart.setNoDataText("暂时没有数据");
        mPieChart.setNoDataTextColor(Color.RED);
        //饼状图中字体的颜色与大小
        mPieChart.setEntryLabelColor(Color.RED);
        mPieChart.setEntryLabelTextSize(10f);
    }
    public static PieData setDataStyle(PieDataSet set){
        set.setSliceSpace(3f);//设置饼状Item之间的间隙
        PieData data=new PieData(set);
        data.setValueFormatter(new PercentFormatter());
        data.setValueTextSize(12f);
        data.setValueTextColor(Color.WHITE);
        return data;
    }
}
